package com.itboye.textileexpes.presenter;

import java.security.PublicKey;
import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.textileexpes.beans.YoufeiBean;
import com.itboye.textileexpes.interfaces.IYouFei;
import com.itboye.textileexpes.repository.YouFeiRepository;
import com.itboye.textileexpres.base.BasePresenter;
import com.itboye.textileexpres.base.ResultEntity;

public class YouFeiPresenter extends BasePresenter implements
		IYouFei<YoufeiBean> {
	public static final String youfei_success = MainPresenter.class.getName()
			+ "_youfei_success";
	public static final String youfei_fail = MainPresenter.class.getName()
			+ "_youfei_fail";
	public static final String shopcaryoufei_success = MainPresenter.class
			.getName() + "_shopcaryoufei_success";
	public static final String shopcaryoufei_fail = MainPresenter.class
			.getName() + "_shopcaryoufei_fail";
	
	
	//商品首页不感兴趣
	public static final String Product_success = MainPresenter.class
			.getName() + "_Product_success";
	public static final String Product_fail = MainPresenter.class
			.getName() + "_Product_fail";

	public YouFeiPresenter(Observer observer) {
		super(observer);
	}

	@Override
	public void add(YoufeiBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(YoufeiBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(YoufeiBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(YoufeiBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public List<YoufeiBean> query(YoufeiBean model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void getYouFei(String uid, String count, String sku_pid,
			String address_id) {
		// TODO Auto-generated method stub
		IYouFei<YoufeiBean> feiRepository = new YouFeiRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(youfei_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(youfei_fail);
						setChanged();
						notifyObservers(result);
					}
				});
		feiRepository.getYouFei(uid, count, sku_pid, address_id);
	}

	@Override
	public void shopcarYouFei(String uid, String ids, String address_id) {
		// TODO Auto-generated method stub
		IYouFei<YoufeiBean> feiRepository = new YouFeiRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(shopcaryoufei_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(shopcaryoufei_fail);
						setChanged();
						notifyObservers(result);
					}
				});
		feiRepository.shopcarYouFei(uid, ids, address_id);
	}

	@Override
	public void onProduct(String id, String uid) {
		// TODO Auto-generated method stub
		IYouFei<YoufeiBean> Product = new YouFeiRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Product_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Product_fail);
						setChanged();
						notifyObservers(result);
					}
				});
		Product.onProduct(id, uid);
	}
}
